﻿using System;
using BO.Solr;
using GUI.Extensions;

namespace GUI.Ajax.News
{
    public partial class MoreNewsFromSolr : System.Web.UI.Page
    {
        private const int PageSize = 10;
        protected void Page_Load(object sender, EventArgs e)
        {
            var keywords = RequestExtensions.Keywords;

            if (!string.IsNullOrEmpty(keywords))
            {
                var exactlySearching = (Request.QueryString["exactlySearching"] ?? string.Empty).Equals("true",
                                                                                                    StringComparison
                                                                                                        .CurrentCultureIgnoreCase);
                var pageIndex = RequestExtensions.PageIndex;
                var result = SolrBO.SearchNewsByKeywords(keywords, pageIndex, PageSize, exactlySearching);
                if (result != null && result.response.numFound > 0)
                {
                    ctrListNewsByTag.DataBind(result.response.docs, string.Empty);
                    return;
                }
                Response.Write(string.Empty);
            }
        }
    }
}